<%--
功能：显示商品目录面包屑导航
--%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="catalog" tagdir="/WEB-INF/tags/catalog"%>

<%@ tag import="org.springframework.context.ApplicationContext" %>
<%@ tag import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ tag import="com.probiz.estore.catalog.service.ProductCategoryManager" %>
<%@ tag import="com.probiz.estore.common.model.catalog.ProductCategory" %>
<%@ tag import="java.util.List" %>

<%@ attribute name="categoryId" type="java.lang.Integer" required="true" description="目录id"%>
<%@ attribute name="isNeedLastCategoryUrl" type="java.lang.Boolean" required="false" description="最后一个目录是否需要url链接，默认false"%>

<%
	ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
	ProductCategoryManager productCategoryManager = (ProductCategoryManager) ctx.getBean("productCategoryManager");
	List<ProductCategory> navigationCategories = productCategoryManager.getNavigationCategories(categoryId);
	request.setAttribute("navigationCategories",navigationCategories);
%>
<a href="${ctxPath}/index.html"><fmt:message key="menu.index"/></a>&gt;
<c:forEach items="${navigationCategories}"  var="category" varStatus="categoryStatus">
	<c:choose>
		<c:when test="${!categoryStatus.last || isNeedLastCategoryUrl}">
			<a <catalog:productCategoryLink categoryId="${category.categoryId}"/>>${category.categoryName}</a>
		</c:when>
		<c:otherwise>
			${category.categoryName}
		</c:otherwise>
	</c:choose>
	
	<c:if test="${!categoryStatus.last}">&gt;</c:if>
</c:forEach>

